package cn.skcks.controller;

import cn.skcks.pojo.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class AjaxController {

	@RequestMapping("/ajax")
	public String test() {
		return "Hello 世界";
	}

	@RequestMapping(value = "/login", method = RequestMethod.POST)
	public String login(@RequestParam("userName") String name, String password) {
		System.out.println("userName => " + name + ", " + "password => " + password);

		if (name.equals("shikong")) {
			if(password.equals("12341234"))
			{
				return "true";
			}
		}

		return "false";
	}

	@RequestMapping("/ajax2")
	public List<User> test2(){
		List<User> userList = new ArrayList<>();

		// 添加数据
		userList.add(new User("时空",21));
		userList.add(new User("时间",20));
		userList.add(new User("时光",20));

		return userList;
	}
}